﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Badder.LiveWriterPlugins.HiLi
{
    public partial class HiLiEditForm : Form
    {
        public HiLiEditForm()
        {
            InitializeComponent();
        }

        private void btnInsert_Click(object sender, EventArgs e)
        {
            string lang = cboLanguages.Text.Trim();
            if(lang=="" || lang.StartsWith("--"))
            {
                MessageBox.Show("请选择一个语言。");
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        public string FormattedCode
        {
            get
            {
                string showLineNumbers = chkDisplayLineNumbers.Checked ? "1" : "0";
                string code = string.Format(txtFormatString.Text.Trim(), cboLanguages.Text.Trim(), showLineNumbers, txtCode.Text);
                return code;
            }
        }

        private void lnkHomePageLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://badder.cn/dotnet-development/code-hili-a-syntax-highlight-plugin-for-windows-live-writer");
        }

        private void btnHelp_Click(object sender, EventArgs e)
        {
            if (btnHelp.Text == "查看说明(&H)>>")
            {
                btnHelp.Text = "查看说明(&H)<<";
                splitContainer1.Panel2Collapsed = false;
            }
            else
            {
                btnHelp.Text = "查看说明(&H)>>";
                splitContainer1.Panel2Collapsed = true;
            }
        }

    }
}
